# 基本数据类型
# https://www.runoob.com/python3/python3-data-type.html
# 笔记

# ---
print('函数返回元组:')
def example(a,b):
	'''
	返回元组：a+10，b+20
	'''
	return(a+10, b+20)

ret = example(1,2);
print(type(ret))
print(ret)

# ---
print('\n函数参数长度可变:')
def varParams(*args):
	'''
	可变长参数，返回参数元组
	'''
	#print(type(args))
	return args

ret = varParams(1,2,3,'a','b')
print(type(ret))
print(ret)

ret = varParams()
print(type(ret))
print(ret)

ret = varParams(['999','zzz'])
print(type(ret))
print(ret)

# ---
print('\n遍历输出字典:')
def dictKeysPrint(dict):
	'''
	遍历输出字典
	'''
	for k in dict:
		print(k, ":", dict[k])

dict1 = {1:'a', 2:'b', 'c':123.456}
dictKeysPrint(dict1)

# ---
print('\nline 50:')
list = [1,2,3,4,5,6,9]
print(list[2])
print(type(list[2])) # class 'int'
print(list[2:3])
print(type(list[2:3])) # class 'list'
print(list[2:2])
print(type(list[2:2])) # class 'list'

# ---
print('\nline 61: type vs isinstance')
class father(object):
	'''
	父类
	'''
	pass

class son(father):
	'''
	子类
	'''
	pass

#if __name__ == '__main__':
print(type(son()) == father) # False
print(isinstance(son(), father)) # True
print(type(son())) # <class '__main__.son'>
print(type(father)) # <class 'type'>
print(type(son)) # <class 'type'>

# ---
print('\nline 82: dictionary items()')
dict1 = {'a':1, 'b':2, 'c':(44,55,66)}
for k,v in dict1.items():
	print(k, '-', v)

# ---
print('\nline 88: dictionary dict(d)')
dict1 = dict([(1, 'a'), ('b', 2)]) # 参数为元组的列表
print(dict1)

dict2 = dict({('aa', 123), ('bb', 999.999)}) # 参数为元组的集合
print(dict2)

dict3 = dict(((1,2), (3,4), ('a','b'))) # 参数为元组的元组
print(dict3)

dict4 = dict([['a','b'], ['c','c'], ['d',123.999]]) # 参数为列表的列表
print(dict4)

# ---
print('\nline 102: 复数')
cp1 = 100 + 1j
print(cp1)
print(cp1.conjugate()) # 复数的共轭复数，100-1j

# ---
print('\nline 108: id(v)')
print(id(56)) # 多次执行，一直不变
print(id(56))
print(id(56))

# 下面的多次执行会有变化
print(id("hello"))
print(id("hello"))
print(id("hello"))

print(id('hello'))
print(id('hello'))
print(id('hello'))

print(id([1,2,3]))
print(id([1,2,3]))

print(id((1,2,3)))
print(id((1,2,3)))

print(id({1,2,3}))
print(id({1,2,3}))


# ---
print('\nline 133: ')
print(range(1,5))
for i in range(1,5): # 1 2 3 4, no 5!
	print(i)

x = [1,2,3,4]
y = [7,8,9,10]
print(zip(x,y))
for i,j in zip(x,y):
	print(i, ", j=", j)

str1 = '        23423 '
print(str1, '.')
print(str1.strip(), '.')
